home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / gnu / glibc108.zip / glibc108 / sysdeps / sparc / sub_n.S < prev    next >
Text File  |  1994-04-26  |  3KB  |  135 lines

  1. ! sparc __mpn_sub_n -- Subtract two limb vectors of the same length > 0 and
  2. ! store difference in a third limb vector.
  3.  
  4. ! Copyright (C) 1992, 1994 Free Software Foundation, Inc.
  5.  
  6. ! This file is part of the GNU MP Library.
  7.  
  8. ! The GNU MP Library is free software; you can redistribute it and/or modify
  9. ! it under the terms of the GNU Library General Public License as published by
  10. ! the Free Software Foundation; either version 2 of the License, or (at your
  11. ! option) any later version.
  12.  
  13. ! The GNU MP Library is distributed in the hope that it will be useful, but
  14. ! WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  15. ! or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
  16. ! License for more details.
  17.  
  18. ! You should have received a copy of the GNU Library General Public License
  19. ! along with the GNU MP Library; see the file COPYING.LIB.  If not, write to
  20. ! the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  21.  
  22.  
  23. ! INPUT PARAMETERS
  24. ! res_ptr    %o0
  25. ! s1_ptr    %o1
  26. ! s2_ptr    %o2
  27. ! size        %o3
  28.  
  29. #include "sysdep.h"
  30.  
  31.     .text
  32.     .align    4
  33.     .global    C_SYMBOL_NAME(__mpn_sub_n)
  34. C_SYMBOL_NAME(__mpn_sub_n):
  35.     ld    [%o1+0],%o4        ! read first limb from s1_ptr
  36.     srl    %o3,4,%g1
  37.     ld    [%o2+0],%o5        ! read first limb from s2_ptr
  38.  
  39.     sub    %g0,%o3,%o3
  40.     andcc    %o3,(16-1),%o3
  41.     be    Lzero
  42.      nop
  43.  
  44.     sll    %o3,2,%o3        ! multiply by 4
  45.     sub    %o0,%o3,%o0        ! adjust res_ptr
  46.     sub    %o1,%o3,%o1        ! adjust s1_ptr
  47.     sub    %o2,%o3,%o2        ! adjust s2_ptr
  48.  
  49.     mov    %o4,%g2
  50.  
  51.     sethi    %hi(Lbase),%g3
  52.     or    %g3,%lo(Lbase),%g3
  53.     sll    %o3,2,%o3        ! multiply by 4
  54.     jmp    %g3+%o3
  55.      mov    %o5,%g3
  56.  
  57. Loop:    subxcc    %g2,%g3,%o3
  58.     add    %o1,64,%o1
  59.     st    %o3,[%o0+60]
  60.     add    %o2,64,%o2
  61.     ld    [%o1+0],%o4
  62.     add    %o0,64,%o0
  63.     ld    [%o2+0],%o5
  64. Lzero:    sub    %g1,1,%g1    ! add 0 + 16r limbs (adjust loop counter)
  65. Lbase:    ld    [%o1+4],%g2
  66.     subxcc    %o4,%o5,%o3
  67.     ld    [%o2+4],%g3
  68.     st    %o3,[%o0+0]
  69.     ld    [%o1+8],%o4    ! add 15 + 16r limbs
  70.     subxcc    %g2,%g3,%o3
  71.     ld    [%o2+8],%o5
  72.     st    %o3,[%o0+4]
  73.     ld    [%o1+12],%g2    ! add 14 + 16r limbs
  74.     subxcc    %o4,%o5,%o3
  75.     ld    [%o2+12],%g3
  76.     st    %o3,[%o0+8]
  77.     ld    [%o1+16],%o4    ! add 13 + 16r limbs
  78.     subxcc    %g2,%g3,%o3
  79.     ld    [%o2+16],%o5
  80.     st    %o3,[%o0+12]
  81.     ld    [%o1+20],%g2    ! add 12 + 16r limbs
  82.     subxcc    %o4,%o5,%o3
  83.     ld    [%o2+20],%g3
  84.     st    %o3,[%o0+16]
  85.     ld    [%o1+24],%o4    ! add 11 + 16r limbs
  86.     subxcc    %g2,%g3,%o3
  87.     ld    [%o2+24],%o5
  88.     st    %o3,[%o0+20]
  89.     ld    [%o1+28],%g2    ! add 10 + 16r limbs
  90.     subxcc    %o4,%o5,%o3
  91.     ld    [%o2+28],%g3
  92.     st    %o3,[%o0+24]
  93.     ld    [%o1+32],%o4    ! add 9 + 16r limbs
  94.     subxcc    %g2,%g3,%o3
  95.     ld    [%o2+32],%o5
  96.     st    %o3,[%o0+28]
  97.     ld    [%o1+36],%g2    ! add 8 + 16r limbs
  98.     subxcc    %o4,%o5,%o3
  99.     ld    [%o2+36],%g3
  100.     st    %o3,[%o0+32]
  101.     ld    [%o1+40],%o4    ! add 7 + 16r limbs
  102.     subxcc    %g2,%g3,%o3
  103.     ld    [%o2+40],%o5
  104.     st    %o3,[%o0+36]
  105.     ld    [%o1+44],%g2    ! add 6 + 16r limbs
  106.     subxcc    %o4,%o5,%o3
  107.     ld    [%o2+44],%g3
  108.     st    %o3,[%o0+40]
  109.     ld    [%o1+48],%o4    ! add 5 + 16r limbs
  110.     subxcc    %g2,%g3,%o3
  111.     ld    [%o2+48],%o5
  112.     st    %o3,[%o0+44]
  113.     ld    [%o1+52],%g2    ! add 4 + 16r limbs
  114.     subxcc    %o4,%o5,%o3
  115.     ld    [%o2+52],%g3
  116.     st    %o3,[%o0+48]
  117.     ld    [%o1+56],%o4    ! add 3 + 16r limbs
  118.     subxcc    %g2,%g3,%o3
  119.     ld    [%o2+56],%o5
  120.     st    %o3,[%o0+52]
  121.     ld    [%o1+60],%g2    ! add 2 + 16r limbs
  122.     subxcc    %o4,%o5,%o3
  123.     ld    [%o2+60],%g3
  124.     st    %o3,[%o0+56]
  125.     subx    %g0,%g0,%o4
  126.     tst    %g1
  127.     bne    Loop
  128.      subcc    %g0,%o4,%g0    ! restore cy (delay slot)
  129.  
  130.     subxcc    %g2,%g3,%o3
  131.     st    %o3,[%o0+60]    ! store most significant limb
  132.  
  133.     retl
  134.      addx    %g0,%g0,%o0    ! return carry-out from most sign. limb
  135.